1. Technical Field
The present invention related generally to an improved data processing system and in particular to an improved method and apparatus for executing Java programs in a data processing system. Still more particularly, the present invention provides a method and apparatus for reducing code size and runtime in an object-oriented environment.
2. Description of Related Art
A computer includes both a physical machine, namely the hardware, and the instructions which cause the physical machine to operate, namely the software. Software includes both application and operating system programs. If the program is simply to do tasks for a user, such as solving specific problems, it is referred to as application software. If a program controls the hardware of the computer and the execution of the application programs, it is called operating system software. System software further includes the operating system, the program that controls the actual computer or central processing unit (CPU), and device drivers that control the input and output devices (I/O) such as printers and terminals.
A number of application programs are usually present waiting to use the CPU. The operating system determines which program will run next, how much of the CPU time it will be allowed to use, and what other computer resources the application will be allowed to access and use. Further, each application program will require a special input or output device and the application program must transfer its data to the operating system, which controls the device drivers.
A network containing a number of computers may be formed by having these computers, also referred to as xe2x80x9cnodesxe2x80x9d or xe2x80x9cnetwork computersxe2x80x9d, communicate with each other over one or more communications links, which is an aggregation which is a computer network. Today, many computer workstations are connected to other workstations, file servers, or other resources in a network. Each computer on a network is connected to the network via an adapter card or other similar means, which provides an ability to establish a communications link to the network.
Applications are often sent to a computer from the server. Java applications are becoming increasingly more prevalent as the type of application sent between server and client computers. Java applications are common on the Internet,and becoming more increasingly common in intranets and in other types of networks used in businesses.
Java is an object oriented programming language and environment focusing on defining data as objects and the methods that may be applied to those objects. Java supports only a single inheritance, meaning that each class can inherit from only one other class at any given time. Java also allows for the creation of totally abstract classes known as interfaces, which allow the defining of methods that may be shared with several classes without regard for how other classes are handling the methods.
The Java virtual machine (JVM) is a virtual computer component that resides only in memory. The JVM allows Java programs to be executed on a different platform as opposed to only the one platform for which the code was compiled. Java programs are compiled for the JVM. In this manner, Java is able to support applications for many types of data processing systems, which may contain a variety of central processing units and operating systems architectures. To enable a Java application to execute on different types of data processing systems, a compiler typically generates an architecture-neutral file formatxe2x80x94the compiled code is executable on many processors, given the presence of the Java run-time system. The architecture-neutral file format consists of bytecode instructions that are generated by a Java compiler and are non-specific to a particular computer architecture. A bytecode is a machine independent code generated by the Java compiler and executed by a Java interpreter. A Java interpreter is a part in the JVM that alternately decodes and interprets a bytecode or bytecodes. These bytecode instructions are designed to be easy to interpret on any computer and easily translated on the fly into native machine code.
A JVM also may include just-in-time (JIT) compilers as an example of a run-time technology used to increase the performance of Java programs. A JIT compiler provides an increase in performance by compiling methods into native machine instructions before executing them. Interpreting Java bytecodes takes more time than executing the equivalent function in native machine code. As a result, native machine code provides for increased application or program execution speeds. Native machine code, however, consumes more storage than Java bytecodes. It is desirable in a Java programming environment to reduce both the amount of memory storage required while increasing execution speed. In this endeavor, JIT compilers have been used to compile bytecode into native machine code to increase execution speed, but end up using even more space because of storing both bytecode and native machine code. In addition, JIT compilers also result in excess time being taken up in performing the JIT compilations. The JIT compiler itself consumes a considerable amount of storage as well.
Thus, it would be advantageous to have an improved method and apparatus for reducing the size of the code while increasing executing speed for code.
The present invention provides a method in a distributed data processing system for optimizing execution of a class. A frequency of execution of paths in bytecodes for methods that are in the class is identified within the distributed data processing system. A portion of the paths is compiled into precompiled native machine code for the data processing system using the history of the frequency of execution of paths. The class is sent to a client in the distributed data processing system.